package cn.initcap.algorithm.leetcode;

/**
 * @author initcap
 * @date Created in 2020/1/11 18:55.
 */
public class LinkedUtil {

    public static ListNode create(int[] arr) {
        ListNode head = new ListNode(arr[0]);

        ListNode cur = head;
        for (int i = 1; i < arr.length; i++) {
            cur.next = new ListNode(arr[i]);
            cur = cur.next;
        }
        return head;
    }

    public static void printLinkedList(ListNode head) {
        ListNode cur = head;
        while (cur != null) {
            System.out.print(cur.val + " -> ");
            cur = cur.next;
        }
        System.out.print("NULL");
    }

}
